<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'action' => Yii::app()->createUrl($this->route),
    'id' => 'searsh_college',
    'method' => 'POST',
        ));
?>

<?php //echo $form->textFieldRow($model,'id',array('class'=>'span5','maxlength'=>10));  ?>
<div>
    <div> <?php echo $form->labelEx($model, 'college_state'); ?>
    </div>

    <div>
        <?php
        $this->widget('ext.bootstrap-select.TbSelect', array(
            'model' => AmanState::model(),
            'attribute' => 'state_name',
            'data' => AmanState::listState(),
            'htmlOptions' => array(
                'onchange' => 'getCollege()'
            //'multiple' => true,
            )
        ));
        ?>
    </div>
</div>
<div>
    <div> <?php echo $form->labelEx($model, 'college_name'); ?>
    </div>
    <div>
        <?php
        $this->widget('ext.bootstrap-select.TbSelect', array(
            'model' => $model,
            'attribute' => 'college_name',
            'data' => AmanCollege::listCollegeName(),
            'htmlOptions' => array(
            //'multiple' => true,
            )
                )
        );
        ?>
    </div>
</div>
<div>
    <div> <?php echo $form->labelEx($model, 'college_address'); ?>
    </div>
    <div>
        <div>
            <?php
            $this->widget('ext.bootstrap-select.TbSelect', array(
                'model' => $model,
                'attribute' => 'college_address',
                'data' => AmanCollege::listCollegeAddress(),
                'htmlOptions' => array(
                //'multiple' => true,
                )
            ));
            ?>
        </div>
    </div> 

    <div class="form-actions1">
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType' => 'submit',
            'type' => 'primary',
            'label' => 'View/Update Your Contact Details',
        ));
        ?>
    </div>
    <div class="btn-toolbar">
        
        <?php
        $this->widget('bootstrap.widgets.TbButtonGroup', array(
            'type' => 'primary', // 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
           
           // 'size' => 'small',
            'buttons' => array(
                
                array('label' => 'I Cannot Find My College Listed Here', 'url' => Yii::app()->createUrl('amanCollege/create')),
            ),
        ));
        ?>
    </div>

<?php $this->endWidget(); ?>

    <!--       , array('ajax' => array(
                    'type' => 'POST', //request type
                    'url' => CController::createUrl('amanCollege/findCollege'), //url to call.
    
                    'update' => '', //selector to update
                    )-->


    <script type="text/javascript" language="javascript">
        $( document ).ready(function() {
            $(".well").hide();
        });
        function getCollege(){
               
            $.ajax({
                url : "<?php echo CController::createUrl('amanCollege/findCollege') ?>",
                type: "POST",
                data: $("#searsh_college").serialize(),
                success: function(data, textStatus, jqXHR)
                {
                    alert(data)
                    $("#AmanCollege_college_name").html(data);
                    //data - response from server
                },
                error: function (jqXHR, textStatus, errorThrown)
                {
 
                }
            });
        }
      
    </script>